home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ussbc23.zip / DEMOS / QR20FRM2.PAS < prev    next >
Pascal/Delphi Source File  |  1997-02-17  |  2KB  |  80 lines

  1. unit qr20frm2;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   Qrctrls, quickrpt, DB, DBTables, ExtCtrls, Qr20ssbc, SSBC;
  8.  
  9. type
  10.   TfrmQRReport = class(TForm)
  11.     QuickRep1: TQuickRep;
  12.     tbCustomers: TTable;
  13.     tbCustomersCompany: TStringField;
  14.     tbCustomersAddr1: TStringField;
  15.     tbCustomersAddr2: TStringField;
  16.     tbCustomersCity: TStringField;
  17.     tbCustomersState: TStringField;
  18.     tbCustomersZip: TStringField;
  19.     DetailBand1: TQRBand;
  20.     TitleBand1: TQRBand;
  21.     QRLabel1: TQRLabel;
  22.     QRDBText1: TQRDBText;
  23.     QRDBText2: TQRDBText;
  24.     QRDBText3: TQRDBText;
  25.     QRDBText4: TQRDBText;
  26.     QRDBText5: TQRDBText;
  27.     QRDBText6: TQRDBText;
  28.     SSBarcode1: TSSBarcode;
  29.     QR20ssBarcode1: TQR20ssBarcode;
  30.     dsCustomers: TDataSource;
  31.     procedure tbCustomersZipGetText(Sender: TField; var Text: string;
  32.       DisplayText: Boolean);
  33.   private
  34.     { Private declarations }
  35.   public
  36.     { Public declarations }
  37.   end;
  38.  
  39. var
  40.   frmQRReport: TfrmQRReport;
  41.  
  42. implementation
  43.  
  44. {$R *.DFM}
  45.  
  46. procedure TfrmQRReport.tbCustomersZipGetText(Sender: TField;
  47.   var Text: string; DisplayText: Boolean);
  48. var
  49.   St : string;
  50.   
  51.   function IsNumeric(St : string) : boolean;
  52.  
  53.   var
  54.     X   : integer;
  55.     AcceptSet : set of char;
  56.   begin
  57.     Result := true;
  58.     AcceptSet := ['0'..'9','-'];
  59.     for X := 1 to Length(St) do
  60.       if not (St[X] in AcceptSet) then
  61.         Result:= false;
  62.   end;
  63.  
  64. begin
  65.   { it is the programmer's responsibility to make sure, when an ssBarcode is linked to a
  66.     DataSource/DataField, that the values being passed to the barcode are legal for that
  67.     symbology.  In this case, we are using PostNet, which requires a numeric zip code.
  68.     Since the DBDEMOS:CUSTOMERS.DB file has some non-U.S. zip codes, we must write a
  69.     GetText handler to throw out any codes that aren't numeric. }
  70.  
  71.   St := Sender.AsString;
  72.   if (not IsNumeric(St)) or (not (Length(St) in [5,9,10,11])) then
  73.     Text := ''
  74.   else
  75.     Text := St;
  76.  
  77. end;
  78.  
  79. end.
  80.